package com.cssw.fyzb.busi.util;

import java.math.BigDecimal;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.Random;

/**
 * @Auther: yangyiqun
 * @Date: 2021/1/21 14:34
 * @Description:
 */
public class NumberUtil {
    public static boolean isWholeNumber(BigDecimal number) {
        return number.remainder(BigDecimal.ONE).compareTo(BigDecimal.ZERO) == 0;
    }

    /**
     * 获取随机数字
     *
     * @param length
     * @return
     */
    public static String getRandomNumber(int length) {
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(10);

            if (i == 0 && number == 0){
                number = 1;
            }
            sb.append(number);
        }
        return sb.toString();
    }
}
